*keep if age44<40

drop group*
drop b_group*
gen group1=(age44>=5&age44<=10)
gen group2=(age44>=11&age44<=24)
gen group3=(age44>=25&age44<=30)



forval x=1/3 {
gen b_group`x'=bartik_standardized*group`x'
}

global treat2   b_group3 b_group2  b_group1

global lasso c.agrishare_1940#age50 c.manushare_1940#age50 c.income_tax_payers38#age50   city#age50 town#age50 


labe var b_group3 "Exposure x (25-30 in 1944)"
labe var b_group2 "Exposure x (11-24 in 1944)"
labe var b_group1 "Exposure x (5-10 in 1944)"

labe var treat_young "Exposure x (\leq 25 in 1944)"


gen treat_young30=bartik_standardized*(age44<=30)
labe var treat_young30 "Exposure x (\leq 30 in 1944)"



foreach x in production_work lower_occ higher_occ yos hdegree{
reghdfe `x' treat_young30, a(age44#laani50 byear fem muni_g  $municontrols_cohort ) cl(muni_g)
estadd local mfe "Yes"
estadd local yfe "Yes"
estimates store `x'1
estadd local controls "Baseline"
}

foreach x in production_work lower_occ higher_occ yos hdegree{
reghdfe `x' $treat2, a(age44#laani50 byear fem muni_g  $municontrols_cohort ) cl(muni_g)
estadd local mfe "Yes"
estadd local yfe "Yes"
estimates store `x'2
estadd local controls "Baseline"
}

foreach x in production_work lower_occ higher_occ yos hdegree{
reghdfe `x' treat_young, a(age44#laani50 byear fem muni_g  $lasso ) cl(muni_g)
estadd local mfe "Yes"
estadd local yfe "Yes"
estimates store `x'3
estadd local controls "E-net controls"
}


gen high_young_2=(bartik_h==2)*young
labe var high_young_2 "High Exposure x (\leq 25 in 1944)"


foreach x in production_work lower_occ higher_occ yos hdegree {
reghdfe `x' high_young_2, a(age44#laani50 byear fem muni_g  $lasso ) cl(muni_g)
estadd local mfe "Yes"
estadd local yfe "Yes"
estimates store `x'4
estadd local controls "Baseline"
}



esttab production_work1 production_work2 production_work3 production_work4  lower_occ1 lower_occ2 lower_occ3 lower_occ4 higher_occ1 higher_occ2 higher_occ3 higher_occ4 ///
using "$temp\tables\oy_robustness_2023_1.tex", ///
mgroups("Production work" "White collar" "Executive", pattern(1 0 0 0 1 0 0 0 1 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) ///
span erepeat(\cmidrule(lr){@span}) ) ///
replace keep(treat_young30 treat_young b_group3 b_group2 b_group1 high_young_2) nonotes ///
b(%9.3f) se(%9.3f)  stats(N  ymean mfe yfe controls  , fmt(0 3) layout(@ @ @) ///
labels("N"   "Y mean" "Cohort Fe" "Muni Fe"  "Controls" )) label star(* .1 ** .05 *** .01) nodepvars nomtitle



esttab yos1 yos2 yos3 yos4 hdegree1 hdegree2 hdegree3 hdegree4 ///
using "$temp\tables\oy_robustness_2023_2.tex", ///
mgroups("Years of education" "Higher degree", pattern(1 0 0 0 1 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) ///
span erepeat(\cmidrule(lr){@span}) ) ///
replace keep(treat_young30 treat_young b_group3 b_group2 b_group1 high_young_2) nonotes ///
b(%9.3f) se(%9.3f)  stats(N  ymean mfe yfe controls  , fmt(0 3) layout(@ @ @) ///
labels("N"   "Y mean" "Cohort Fe" "Muni Fe"  "Controls" )) label star(* .1 ** .05 *** .01) nodepvars nomtitle




